<?php

/**
 * MyProjectNameHere <http://www.example.com>
 * Model Class
 *
 * It is recommended to extend Model classes from WWW_Factory in order to 
 * provide various useful functions and API access for the Model.
 *
 * @package    Factory
 * @author     DeveloperNameHere <email@example.com>
 * @copyright  Copyright (c) 2012, ProjectOwnerNameHere
 * @license    Unrestricted
 * @tutorial   /doc/pages/guide_mvc.htm
 * @since      1.0.0
 * @version    1.0.0
 */

class WWW_model_about extends WWW_Factory {

	/**
	 * It is recommended to define all data variables here. Usually the 
	 * data variables have the same names as the column names of database 
	 * rows from a table.
	 */	
	public $conn;
	/**
	 * Alternative to __construct()
	 *
	 * WWW_Factory does not allow to overwrite __construct() method, so 
	 * this __initialize() is used instead and loaded automatically when 
	 * object is created.
	 *
	 * @return boolean
	 */
	public function __initialize()
	{
		/* require('engine/class.www-database.php');
		$this->conn=new WWW_Database(); */
		require('engine/include_dao.php');
		return true;
		
	}
	public function create_privacypolicy($data)
	{		//print_r($data);exit;
		$privacyPolicy = new PrivacyPolicy();
		$privacyPolicy->p_description = $data['p_description'];
		$privacyPolicy->created_date = date("Y-m-d h:i:s");
		$privacyPolicy->updated_date = date("Y-m-d h:i:s");
		$result = DAOFactory::getPrivacyPolicyDAO()->insert_privacypolicy($privacyPolicy);
		print_r($result);exit;
			
	/* $query="insert into `privacy_policy` (p_description,created_date,updated_date) VALUES ('".$data['description']."','".date("Y-m-d H:i:s")."','".date("Y-m-d H:i:s")."')";
	$result=$this->conn->dbCommand($query);	 */
		//$this->db->last_query();exit;
	if($result !== 0){
			return array('message'=>'Privacy Policy successfully created');			
		}else{
			return array('message'=>'Privacy Policy Creation Failed');
		}	
	}
	public function edit_privacypolicy($data)
	{	
		$privacyPolicy = new PrivacyPolicy();
		$privacyPolicy->privacyPolicy_id = $data['privacy_policy_id'];
		$privacyPolicy->status = $data['status'];
		$privacyPolicy->p_description = $data['p_description'];
		$privacyPolicy->updated_date = date("Y-m-d h:i:s");
		$result = DAOFactory::getPrivacyPolicyDAO()->update_privacypolicy($privacyPolicy);
		//print_r($result);exit;
		
/* 	$query="update `privacy_policy` set p_description='".$data['description']."',updated_date='".date("Y-m-d H:i:s")."' where privacy_policy_id=".$data['privacy_policy_id'];
		$result=$this->conn->dbCommand($query);	 */	
		if($result !== 0){
			return array('message'=>'Updated Successfully');			
		}else{
			return array('message'=>'Updates Failed');
		}	
	
	}
	public function get_privacypolicy($data)
	{		
		$privacyPolicy = new PrivacyPolicy();
		$result = DAOFactory::getPrivacyPolicyDAO()->load_privacypolicy($privacyPolicy);
		//print_r($result);exit;
			
		/* $query="SELECT * FROM `privacy_policy`";
		$result=$this->conn->dbMultiple($query);	 */	
		if($result !== ''){
			return array('message'=>'Submodule type data','result'=>$result);		
		}else{
			return array('message'=>'submodule by id is failed');
		}	
	
	}
	public function delete_privacypolicy($data)
	{		
		$privacyPolicy = new PrivacyPolicy();
		$privacyPolicy->privacyPolicy_id = $data['privacy_policy_id'];
		$privacyPolicy->status = $data['status'];
		$result = DAOFactory::getPrivacyPolicyDAO()->delete_privacypolicy($privacyPolicy);
		//print_r($result);exit;
			
		
		/* $query="update `privacy_policy` set status='".$data['status']."' where privacy_policy_id='".$data['privacy_policy_id']."'";
		$data=$this->conn->dbCommand($query); */
		if($result !== 0)
			return array('message'=>"Module status changed Successfully");		
		else
			return array('message'=>'Module status changed failed');
	}
	public function create_service($data)
	{		 
			$service = new Service();
		$service->service_description = $data['service_description'];
		$service->created_date = date("Y-m-d h:i:s");
		$service->updated_date = date("Y-m-d h:i:s");
		$result = DAOFactory::getServicesDAO()->insert_service($service);
		//print_r($result);exit;
			
	/* $query="insert into `services` (service_description,created_date,updated_date) VALUES ('".$data['description']."','".date("Y-m-d H:i:s")."','".date("Y-m-d H:i:s")."')";
	$result=$this->conn->dbCommand($query);	 */
		//$this->db->last_query();exit;
	if($result !== 0){
			return array('message'=>'Service successfully created');			
		}else{
			return array('message'=>'Service Creation Failed');
		}	
	}
	
	public function edit_service($data)
	{
		$service = new Service();
		$service->service_description = $data['service_description'];
		$service->service_id = $data['service_id'];
		$service->status = $data['status'];
		$service->updated_date = date("Y-m-d h:i:s");
		$result = DAOFactory::getServicesDAO()->update_service($service);
		//print_r($result);exit;
		
		/* $query="update `services` set service_description='".$data['description']."',updated_date='".date("Y-m-d H:i:s")."' where service_id=".$data['service_id'];
		$result=$this->conn->dbCommand($query);		 */
		if($result){
			return array('message'=>'Updated Successfully');			
		}else{
			return array('message'=>'Updates Failed');
		}	
	
	}
	
	public function get_service($data)
	{		
		$service = new Service();
		$result = DAOFactory::getServicesDAO()->load_service($service);
		print_r($result);exit;
		
		//print_r($data);exit;
	/* $query="SELECT * FROM `services`";
		$result=$this->conn->dbMultiple($query);	 */	
		if($result !== ''){
			return array('message'=>'Submodule type data','result'=>$result);			
		}else{
			return array('message'=>'Submodule by id is failed');
		}	
	
	}
	
	public function delete_service($data)
	{		
		$service = new Service();
		$service->service_id = $data['service_id'];
		$service->status = $data['status'];
		$result = DAOFactory::getServicesDAO()->delete_service($service);
		//print_r($result);exit;
		
		/* $query="update `services` set status='".$data['status']."' where service_id='".$data['service_id']."'";
		$data=$this->conn->dbCommand($query); */
		if($result !== 0)
			return array('message'=>"Submodule Deleted Successfully");		
		else
			return array('message'=>'Submodule Deletion Fails');
	}
	
	public function create_ads($data)
	{	
		$adsinfo = new AdsInfo();
		$adsinfo->ads_description = $data['ads_description'];
		$adsinfo->created_date = date("Y-m-d h:i:s");
		$adsinfo->updated_date = date("Y-m-d h:i:s");
		$result = DAOFactory::getAdsInfoDAO()->insert_ads($adsinfo);
		//print_r($result);exit;
	/* $query="insert into `ads_info` (ads_description,created_date,updated_date) VALUES ('".$data['description']."','".date("Y-m-d H:i:s")."','".date("Y-m-d H:i:s")."')";
	$result=$this->conn->dbCommand($query);	
		print_r($query);exit; */
	if($result!=""){
			return array('message'=>'Ads successfully created');			
		}else{
			return array('message'=>'Ads Creation Failed');
		}	
	}
	
	public function edit_ads($data)
	{
			$adsinfo = new AdsInfo();
		$adsinfo->ads_description = $data['ads_description'];
		$adsinfo->updated_date = date("Y-m-d h:i:s");
		$adsinfo->ads_id = $data['ads_id'];
		$result = DAOFactory::getAdsInfoDAO()->update_ads($adsinfo);
		//print_r($result);exit;
		/* $query="update `ads_info` set ads_description='".$data['description']."',updated_date='".date("Y-m-d H:i:s")."' where ads_id=".$data['ads_id'];
		$result=$this->conn->dbCommand($query);		 */
		if($result==1){
			return array('message'=>'Updated Successfully');			
		}else{
			return array('message'=>'Updates Failed');
		}	
	
	}
	
	public function get_ads($data)
	{		$adsinfo = new AdsInfo();
		$result = DAOFactory::getAdsInfoDAO()->All_ads($adsinfo);
		//print_r($result);exit;
	/* $query="SELECT * FROM `ads_info`";
		$result=$this->conn->dbMultiple($query); */		
		if($result!==""){
			return array('message'=>'Ads type data','result'=>$result);			
		}else{
			return array('message'=>'Ads by id is failed');
		}	
	
	}
	
	public function delete_ads($data)
	{	
		$adsinfo = new AdsInfo();
		$adsinfo->status = $data['status'];
		$adsinfo->ads_id = $data['ads_id'];
		$result = DAOFactory::getAdsInfoDAO()->delete_ads($adsinfo);
		/* print_r($result);exit;
		$query="update `ads_info` set status='".$data['status']."' where ads_id='".$data['ads_id']."'";
		$data=$this->conn->dbCommand($query); */
		if($result==1)
			return array('message'=>"Ads Deleted Successfully");		
		else
			return array('message'=>'Ads Deletion Fails');
	}
	public function create_abtazindia($data)
	{			
		$aboutAzindia = new AboutAzindia();
		$aboutAzindia->about_description = $data['about_description'];
		$aboutAzindia->created_date = date("Y-m-d h:i:s");
		$aboutAzindia->updated_date = date("Y-m-d h:i:s");
		$result = DAOFactory::getAboutAzindiaDAO()->insert_abtazindia($aboutAzindia);
		//print_r($result);exit;
		
	/* $query="insert into `about_azindia` (about_description,created_date,updated_date) VALUES ('".$data['description']."','".date("Y-m-d H:i:s")."','".date("Y-m-d H:i:s")."')";
	$result=$this->conn->dbCommand($query);	 */
		//print_r($query);exit;
	if($result !== 0){
			return array('message'=>'about Azindia successfully created');			
		}else{
			return array('message'=>'about Azindia Creation Failed');
		}	
	}
	
	public function edit_abtazindia($data)
	{			
			$aboutAzindia = new AboutAzindia();
		$aboutAzindia->about_description = $data['about_description'];
		$aboutAzindia->status = $data['status'];
		$aboutAzindia->about_id = $data['about_id'];
		$aboutAzindia->updated_date = date("Y-m-d h:i:s");
		$result = DAOFactory::getAboutAzindiaDAO()->update_abtazindia($aboutAzindia);
		//print_r($result);exit;
		
		/* $query="update `about_azindia` set about_description='".$data['description']."',updated_date='".date("Y-m-d H:i:s")."' where about_id=".$data['about_id'];
		$result=$this->conn->dbCommand($query);	 */	
		if($result !== 0){
			return array('message'=>'Updated Successfully');			
		}else{
			return array('message'=>'Updates Failed');
		}	
	
	}
	
	public function get_abtazindia($data)
	{		
			$aboutAzindia = new AboutAzindia();
		$result = DAOFactory::getAboutAzindiaDAO()->all_abtazindia($aboutAzindia);
		//print_r($result);exit;
			
		//print_r($data);exit;
	/* $query="SELECT * FROM `about_azindia`";
		$result=$this->conn->dbMultiple($query);		 */
		if($result !== ''){
			return array('message'=>'Ads type data','result'=>$result);			
		}else{
			return array('message'=>'Ads by id is failed');
		}	
	
	}
	
	public function delete_abtazindia($data)
	{		
			$aboutAzindia = new AboutAzindia();
		$aboutAzindia->status = $data['status'];
		$aboutAzindia->about_id = $data['about_id'];
		$result = DAOFactory::getAboutAzindiaDAO()->delete_abtazindia($aboutAzindia);
		//print_r($result);exit;
		
	
		/* $query="update `about_azindia` set status='".$data['status']."' where about_id='".$data['about_id']."'";
		$data=$this->conn->dbCommand($query); */
		if($result !== 0)
			return array('message'=>"Ads Deleted Successfully");		
		else
			return array('message'=>'Ads Deletion Fails');
	}
	
	
}
	
?>